Skip to content

fix: resolve sibling refs alongside $ref#2362

Merged
vadyvas merged 9 commits intomainfrom
fix/bundler-sibling-refs
Oct 22, 2025
Merged

fix: resolve sibling refs alongside $ref#2362
vadyvas merged 9 commits intomainfrom
fix/bundler-sibling-refs

Conversation

@vadyvas
Copy link
Contributor

@vadyvas vadyvas commented Oct 13, 2025

What/Why/How?

Fix handling of description/summary when they are $ref siblings next to a schema $ref so they resolve correctly and override the target schemas.

Why: Previously, bundling left description as a $ref object when used alongside another $ref, matching the bug described in the linked issue.

# openapi.yaml
openapi: 3.1.0
paths:
  /test:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  field:
                    description:
                      $ref: './components/schemas/description.md'
                    $ref: '#/components/schemas/Child'

components:
  schemas:
    Child:
      type: object
      properties:
        name:
          type: string

Reference

Fixes: СLI issue #1907

Testing

  • Added unit and e2e tests
  • Existing suites pass locally.

Screenshots (optional)

Check yourself

  • Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • All new/updated code is covered by tests
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 5a14c1f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/openapi-core Patch
@redocly/cli Patch
@redocly/respect-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2025

Command Mean [s] Min [s] Max [s] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 1.439 ± 0.013 1.417 1.459 1.01 ± 0.02
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 1.430 ± 0.026 1.403 1.486 1.00

@vadyvas vadyvas marked this pull request as ready for review October 14, 2025 07:16
@vadyvas vadyvas requested review from a team as code owners October 14, 2025 07:16
propType = { name: 'scalar', properties: {} };
}

if (isRef(node[propName]) && type.name === 'Schema' && propType?.name === 'scalar') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not hardcode name of the type here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • removed the hardcoded Schema check and now resolve scalar sibling $refs generically
  • added a unit test for this case

@vadyvas vadyvas changed the title fix: resolving sibling refs alongside $ref in Schema contexts fix: resolve sibling refs alongside $ref in schema contexts Oct 22, 2025
@vadyvas vadyvas changed the title fix: resolve sibling refs alongside $ref in schema contexts fix: resolve sibling refs alongside $ref Oct 22, 2025
@vadyvas vadyvas merged commit ed9b2d4 into main Oct 22, 2025
36 checks passed
@vadyvas vadyvas deleted the fix/bundler-sibling-refs branch October 22, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redocly bundle doesn't correctly render description $ref with $ref sibling

4 participants